$(function() {
	$("#JenjangPendidikan").change(function() {
		$.getJSON("../json/pendidikan.php", {tipe: 'jenjang', id: $("#JenjangPendidikan").val()}, function(response) {
			if(response.length > 0) {
				$("#FakultasPendidikan").empty();
				$("#FakultasPendidikan").empty().append("<option value=''>-Select-</option>");
				$("#JurusanPendidikan").empty().append("<option value=''>-Select-</option>");
				for(i=0; i<response.length; i++) {
					$("#FakultasPendidikan").append("<option value='" + response[i].id + "'>" + response[i].nama + "</option>");
				}
			} else {
				$("#FakultasPendidikan").empty().append("<option value=''>-Select-</option>");
				$("#JurusanPendidikan").empty().append("<option value=''>-Select-</option>");
			}
		});
	});
	
	$("#FakultasPendidikan").change(function() {
		$.getJSON("../json/pendidikan.php", {tipe: 'fakultas', id: $("#FakultasPendidikan").val()}, function(response) {
			if(response.length > 0) {
				$("#JurusanPendidikan").empty();
				for(i=0; i<response.length; i++) {
					$("#JurusanPendidikan").append("<option value='" + response[i].id + "'>" + response[i].nama + "</option>");
				}
			} else {
				$("#FakultasPendidikan").empty().append("<option value=''>-Select-</option>");
			}
		});
	});
});